package com.UnionPayCenter.account.enums;

import com.UnionPayCenter.enums.CodeBaseEnum;
import com.UnionPayCenter.exception.ApiException;

/**
 * 支付渠道枚举
 */
public enum PayChannelEnum implements CodeBaseEnum {

    UNION_PAY(1, "银联支付"),
    WECHAT_PAY(2, "微信支付"),
    ALI_PAY(3, "阿里支付"),
    BALANCE_PAY(4, "余额支付"),
    IMPORT(5, "外部导入"),
    ;

    private int code;

    private String msg;

    PayChannelEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static PayChannelEnum getEnum(int code) {
        for (PayChannelEnum ele : PayChannelEnum.values()) {
            if (ele.code == code) {
                return ele;
            }
        }
        throw new ApiException(404, "不正确的支付渠道");
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String msg() {
        return msg;
    }
}
